package com.vms.control.weight.model;

import java.util.Date;

import com.vms.control.weight.model.WeightTime.DayPart;

public class Weight {
	private DayPart dayPart;
	private float weightValue;
	private Date date;

	public Weight(DayPart dayPart, float weightValue, Date date) {
		super();
		this.dayPart = dayPart;
		this.weightValue = weightValue;
		this.date = date;
	}

	public DayPart getDayPart() {
		return dayPart;
	}

	public void setDayPart(DayPart dayPart) {
		this.dayPart = dayPart;
	}

	public float getWeightValue() {
		return weightValue;
	}

	public void setWeightValue(float weightValue) {
		this.weightValue = weightValue;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
	public boolean equals(Object o) {
		if(o == null) return false;
		if(o == this) return true;
		if(!(o instanceof Weight))return false;
		Weight w = (Weight)o;
		return (w.dayPart.equals(this.dayPart)
				&& w.date.equals(this.date)
				&& compareWeightValues(w.weightValue,this.weightValue));
	}
	
	private static boolean compareWeightValues(float l, float r) {
		return Float.compare(l, r) == 0;
	}

	@Override
	public String toString() {
		return String.format("[ Weight %d | weightValue:%f dayPart:%s date:%s ]",
				hashCode(),
				getWeightValue(),
				getDayPart().toString(),
				getDate().toString());
	}
}
